<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>选择你喜欢的书</title>
	</head>
	<body>
		<p>
			选择你喜欢的书：
			<input type="radio" name="book" onclick="book()" />我和狗狗一起活下来
			<input type="radio" name="book" onclick="book()" />雾霾来了怎么办
		</p>
			<div><img src="" alt="" id="image" onclick="img()"/><span></span></div>
		<script>
			function book(){
			var ele=document.getElementsByName("book");
			var img=document.getElementById("image");
			if(ele[0].checked){
				alert(0);
				img.setAttribute("src","prictice02/images/dog.jpg");
				img.setAttribute("alt","我和狗狗一起活下来");
				img.nextSibling.innerHTML="我和狗狗一起活下来";
				alert(img.nextSibling.nodeType);
			}else if(ele[1].checked){
				img.setAttribute("src","prictice02/images/mai.jpg");
				img.setAttribute("alt","灰霾来了怎么办");
				img.nextSibling.innerHTML="灰霾来了怎么办";
			}
			}
			function img(){
				var alt=document.getElementById("image").getAttribute("alt");
				alert(alt);
				
			}
		</script>
	</body>
	
</html>
